package model.pages;

import model.blocks.ButtonsBlock;
import model.blocks.SearchBlock;
import net.thucydides.core.annotations.DefaultUrl;
import org.openqa.selenium.WebDriver;
import utils.PropertyLoader;


@DefaultUrl("http://www.paycheckcity.com/")

public class MainPage extends BasePage {

    private final static String BASE_URL
            = PropertyLoader.loadProperty("base.url");

    SearchBlock searchBlock;
    ButtonsBlock buttonsBlock;

    public MainPage(WebDriver driver) {
        super(driver);
        driver.get(BASE_URL);
        searchBlock = new SearchBlock(driver);
    }

    public MainPage setWhereToGo(String whereToGo) {
        searchBlock.setWhereToGo(whereToGo);
        return this;
    }


    public MainPage setCheckIn(String checkIn) {
        searchBlock.setCheckIn(checkIn);
        return this;
    }


    public MainPage setCheckOut(String checkOut) {
        searchBlock.setCheckOut(checkOut);
        return this;
    }

    public MainPage setGuests(String guests) {
        searchBlock.setGuests(guests);
        return this;
    }

    public SearchResultPage clickSearchButton() throws InterruptedException {
        buttonsBlock.clickSearchButton();
        return new SearchResultPage(driver);
    }
}
